package com.feng.modules.security;

import java.util.Map;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

public class SecurityInterceptor extends AbstractInterceptor {
	private static final long serialVersionUID = -8625356913977179801L;
	private String loginResult = "login";

	public String intercept(ActionInvocation invocation) throws Exception {
		Map user = (Map) invocation.getInvocationContext().getSession()
				.get("user");
		String result;
		if (user != null)
			result = invocation.invoke();
		else {
			result = this.loginResult;
		}
		return result;
	}

	public void setLoginResult(String loginResult) {
		this.loginResult = loginResult;
	}
}